/*   1:    */ package org.intellij.images.ui;
/*   2:    */ 
/*   3:    */

import com.intellij.util.containers.ContainerUtil;
import org.intellij.images.editor.ImageDocument;
import org.intellij.images.options.GridOptions;
import org.intellij.images.options.TransparencyChessboardOptions;
import org.jetbrains.annotations.NonNls;

import javax.swing.*;
import javax.swing.event.ChangeEvent;
import javax.swing.event.ChangeListener;
import java.awt.*;
import java.awt.image.BufferedImage;
import java.util.List;

/*   4:    */
/*   5:    */
/*   6:    */
/*   7:    */
/*   8:    */
/*   9:    */
/*  10:    */
/*  11:    */
/*  12:    */
/*  13:    */
/*  14:    */
/*  15:    */
/*  16:    */
/*  17:    */
/*  18:    */
/*  19:    */ 
/*  20:    */ public class ImageComponent
/*  21:    */   extends JComponent
/*  22:    */ {
/*  23:    */   @NonNls
/*  24:    */   private static final String a = "TransparencyChessboard.cellSize";
/*  25:    */   @NonNls
/*  26:    */   private static final String b = "TransparencyChessboard.whiteColor";
/*  27:    */   @NonNls
/*  28:    */   private static final String c = "TransparencyChessboard.blackColor";
/*  29:    */   @NonNls
/*  30:    */   private static final String d = "TransparencyChessboard.visible";
/*  31:    */   @NonNls
/*  32:    */   private static final String e = "Grid.lineZoomFactor";
/*  33:    */   @NonNls
/*  34:    */   private static final String f = "Grid.lineSpan";
/*  35:    */   @NonNls
/*  36:    */   private static final String g = "Grid.lineColor";
/*  37:    */   @NonNls
/*  38:    */   private static final String h = "Grid.visible";
/*  39:    */   @NonNls
/*  40:    */   private static final String i = "ImageComponentUI";
/*  41:    */   
/*  42:    */   static
/*  43:    */   {
/*  44: 65 */     UIManager.getDefaults().put("ImageComponentUI", ImageComponentUI.class.getName());
/*  45:    */   }
/*  46:    */   
/*  47: 68 */   private final ImageDocument j = new ImageDocumentImpl(null);
/*  48: 69 */   private final Grid k = new Grid(null);
/*  49: 70 */   private final Chessboard l = new Chessboard(null);
/*  50:    */   
/*  51:    */   public ImageComponent()
/*  52:    */   {
/*  53: 73 */     updateUI();
/*  54:    */   }
/*  55:    */   
/*  56:    */   public ImageDocument getDocument()
/*  57:    */   {
/*  58: 77 */     return this.j;
/*  59:    */   }
/*  60:    */   
/*  61:    */   public void setTransparencyChessboardCellSize(int paramInt)
/*  62:    */   {
/*  63: 81 */     int m = this.l.getCellSize();
/*  64: 82 */     if (m != paramInt)
/*  65:    */     {
/*  66: 83 */       this.l.setCellSize(paramInt);
/*  67: 84 */       firePropertyChange("TransparencyChessboard.cellSize", m, paramInt);
/*  68:    */     }
/*  69:    */   }
/*  70:    */   
/*  71:    */   public void setTransparencyChessboardWhiteColor(Color paramColor)
/*  72:    */   {
/*  73: 89 */     Color localColor = this.l.getWhiteColor();
/*  74: 90 */     if (((localColor != null) && (!localColor.equals(paramColor))) || ((localColor == null) && (paramColor != null)))
/*  75:    */     {
/*  76: 91 */       this.l.setWhiteColor(paramColor);
/*  77: 92 */       firePropertyChange("TransparencyChessboard.whiteColor", localColor, paramColor);
/*  78:    */     }
/*  79:    */   }
/*  80:    */   
/*  81:    */   public void setTransparencyChessboardBlankColor(Color paramColor)
/*  82:    */   {
/*  83: 97 */     Color localColor = this.l.getBlackColor();
/*  84: 98 */     if (((localColor != null) && (!localColor.equals(paramColor))) || ((localColor == null) && (paramColor != null)))
/*  85:    */     {
/*  86: 99 */       this.l.setBlackColor(paramColor);
/*  87:100 */       firePropertyChange("TransparencyChessboard.blackColor", localColor, paramColor);
/*  88:    */     }
/*  89:    */   }
/*  90:    */   
/*  91:    */   public void setTransparencyChessboardVisible(boolean paramBoolean)
/*  92:    */   {
/*  93:105 */     boolean bool = this.l.isVisible();
/*  94:106 */     if (bool != paramBoolean)
/*  95:    */     {
/*  96:107 */       this.l.setVisible(paramBoolean);
/*  97:108 */       firePropertyChange("TransparencyChessboard.visible", bool, paramBoolean);
/*  98:    */     }
/*  99:    */   }
/* 100:    */   
/* 101:    */   public int getTransparencyChessboardCellSize()
/* 102:    */   {
/* 103:113 */     return this.l.getCellSize();
/* 104:    */   }
/* 105:    */   
/* 106:    */   public Color getTransparencyChessboardWhiteColor()
/* 107:    */   {
/* 108:117 */     return this.l.getWhiteColor();
/* 109:    */   }
/* 110:    */   
/* 111:    */   public Color getTransparencyChessboardBlackColor()
/* 112:    */   {
/* 113:121 */     return this.l.getBlackColor();
/* 114:    */   }
/* 115:    */   
/* 116:    */   public boolean isTransparencyChessboardVisible()
/* 117:    */   {
/* 118:125 */     return this.l.isVisible();
/* 119:    */   }
/* 120:    */   
/* 121:    */   public void setGridLineZoomFactor(int paramInt)
/* 122:    */   {
/* 123:129 */     int m = this.k.getLineZoomFactor();
/* 124:130 */     if (m != paramInt)
/* 125:    */     {
/* 126:131 */       this.k.setLineZoomFactor(paramInt);
/* 127:132 */       firePropertyChange("Grid.lineZoomFactor", m, paramInt);
/* 128:    */     }
/* 129:    */   }
/* 130:    */   
/* 131:    */   public void setGridLineSpan(int paramInt)
/* 132:    */   {
/* 133:137 */     int m = this.k.getLineSpan();
/* 134:138 */     if (m != paramInt)
/* 135:    */     {
/* 136:139 */       this.k.setLineSpan(paramInt);
/* 137:140 */       firePropertyChange("Grid.lineSpan", m, paramInt);
/* 138:    */     }
/* 139:    */   }
/* 140:    */   
/* 141:    */   public void setGridLineColor(Color paramColor)
/* 142:    */   {
/* 143:145 */     Color localColor = this.k.getLineColor();
/* 144:146 */     if (((localColor != null) && (!localColor.equals(paramColor))) || ((localColor == null) && (paramColor != null)))
/* 145:    */     {
/* 146:147 */       this.k.setLineColor(paramColor);
/* 147:148 */       firePropertyChange("Grid.lineColor", localColor, paramColor);
/* 148:    */     }
/* 149:    */   }
/* 150:    */   
/* 151:    */   public void setGridVisible(boolean paramBoolean)
/* 152:    */   {
/* 153:153 */     boolean bool = this.k.isVisible();
/* 154:154 */     if (bool != paramBoolean)
/* 155:    */     {
/* 156:155 */       this.k.setVisible(paramBoolean);
/* 157:156 */       firePropertyChange("Grid.visible", bool, paramBoolean);
/* 158:    */     }
/* 159:    */   }
/* 160:    */   
/* 161:    */   public int getGridLineZoomFactor()
/* 162:    */   {
/* 163:161 */     return this.k.getLineZoomFactor();
/* 164:    */   }
/* 165:    */   
/* 166:    */   public int getGridLineSpan()
/* 167:    */   {
/* 168:165 */     return this.k.getLineSpan();
/* 169:    */   }
/* 170:    */   
/* 171:    */   public Color getGridLineColor()
/* 172:    */   {
/* 173:169 */     return this.k.getLineColor();
/* 174:    */   }
/* 175:    */   
/* 176:    */   public boolean isGridVisible()
/* 177:    */   {
/* 178:173 */     return this.k.isVisible();
/* 179:    */   }
/* 180:    */   
/* 181:    */   public void setCanvasSize(int paramInt1, int paramInt2)
/* 182:    */   {
/* 183:177 */     setSize(paramInt1 + 4, paramInt2 + 4);
/* 184:    */   }
/* 185:    */   
/* 186:    */   public void setCanvasSize(Dimension paramDimension)
/* 187:    */   {
/* 188:181 */     setCanvasSize(paramDimension.width, paramDimension.height);
/* 189:    */   }
/* 190:    */   
/* 191:    */   public Dimension getCanvasSize()
/* 192:    */   {
/* 193:185 */     Dimension localDimension = getSize();
/* 194:186 */     return new Dimension(localDimension.width - 4, localDimension.height - 4);
/* 195:    */   }
/* 196:    */   
/* 197:    */   public String getUIClassID()
/* 198:    */   {
/* 199:190 */     return "ImageComponentUI";
/* 200:    */   }
/* 201:    */   
/* 202:    */   public void updateUI()
/* 203:    */   {
/* 204:194 */     setUI(UIManager.getUI(this));
/* 205:    */   }
/* 206:    */   
/* 207:    */   private static final class ImageDocumentImpl
/* 208:    */     implements ImageDocument
/* 209:    */   {
/* 210:198 */     private final List<ChangeListener> a = ContainerUtil.createLockFreeCopyOnWriteList();
/* 211:    */     private BufferedImage b;
/* 212:    */     private String c;
/* 213:    */     private Image d;
/* 214:    */     
/* 215:    */     public Image getRenderer()
/* 216:    */     {
/* 217:204 */       return this.d;
/* 218:    */     }
/* 219:    */     
/* 220:    */     public BufferedImage getValue()
/* 221:    */     {
/* 222:208 */       return this.b;
/* 223:    */     }
/* 224:    */     
/* 225:    */     public void setValue(BufferedImage paramBufferedImage)
/* 226:    */     {
/* 227:212 */       this.b = paramBufferedImage;
/* 228:213 */       this.d = (paramBufferedImage != null ? Toolkit.getDefaultToolkit().createImage(paramBufferedImage.getSource()) : null);
/* 229:214 */       a(new ChangeEvent(this));
/* 230:    */     }
/* 231:    */     
/* 232:    */     public String getFormat()
/* 233:    */     {
/* 234:218 */       return this.c;
/* 235:    */     }
/* 236:    */     
/* 237:    */     public void setFormat(String paramString)
/* 238:    */     {
/* 239:223 */       this.c = paramString;
/* 240:224 */       a(new ChangeEvent(this));
/* 241:    */     }
/* 242:    */     
/* 243:    */     private void a(ChangeEvent paramChangeEvent)
/* 244:    */     {
/* 245:228 */       for (ChangeListener localChangeListener : this.a) {
/* 246:229 */         localChangeListener.stateChanged(paramChangeEvent);
/* 247:    */       }
/* 248:    */     }
/* 249:    */     
/* 250:    */     public void addChangeListener(ChangeListener paramChangeListener)
/* 251:    */     {
/* 252:234 */       this.a.add(paramChangeListener);
/* 253:    */     }
/* 254:    */     
/* 255:    */     public void removeChangeListener(ChangeListener paramChangeListener)
/* 256:    */     {
/* 257:238 */       this.a.remove(paramChangeListener);
/* 258:    */     }
/* 259:    */   }
/* 260:    */   
/* 261:    */   private static final class Chessboard
/* 262:    */   {
/* 263:243 */     private int a = 5;
/* 264:244 */     private Color b = TransparencyChessboardOptions.DEFAULT_WHITE_COLOR;
/* 265:245 */     private Color c = TransparencyChessboardOptions.DEFAULT_BLACK_COLOR;
/* 266:246 */     private boolean d = false;
/* 267:    */     
/* 268:    */     public int getCellSize()
/* 269:    */     {
/* 270:249 */       return this.a;
/* 271:    */     }
/* 272:    */     
/* 273:    */     public void setCellSize(int paramInt)
/* 274:    */     {
/* 275:253 */       this.a = paramInt;
/* 276:    */     }
/* 277:    */     
/* 278:    */     public Color getWhiteColor()
/* 279:    */     {
/* 280:257 */       return this.b;
/* 281:    */     }
/* 282:    */     
/* 283:    */     public void setWhiteColor(Color paramColor)
/* 284:    */     {
/* 285:261 */       this.b = paramColor;
/* 286:    */     }
/* 287:    */     
/* 288:    */     public Color getBlackColor()
/* 289:    */     {
/* 290:265 */       return this.c;
/* 291:    */     }
/* 292:    */     
/* 293:    */     public void setBlackColor(Color paramColor)
/* 294:    */     {
/* 295:269 */       this.c = paramColor;
/* 296:    */     }
/* 297:    */     
/* 298:    */     public boolean isVisible()
/* 299:    */     {
/* 300:273 */       return this.d;
/* 301:    */     }
/* 302:    */     
/* 303:    */     public void setVisible(boolean paramBoolean)
/* 304:    */     {
/* 305:277 */       this.d = paramBoolean;
/* 306:    */     }
/* 307:    */   }
/* 308:    */   
/* 309:    */   private static final class Grid
/* 310:    */   {
/* 311:282 */     private int a = 3;
/* 312:283 */     private int b = 1;
/* 313:284 */     private Color c = GridOptions.DEFAULT_LINE_COLOR;
/* 314:285 */     private boolean d = false;
/* 315:    */     
/* 316:    */     public int getLineZoomFactor()
/* 317:    */     {
/* 318:288 */       return this.a;
/* 319:    */     }
/* 320:    */     
/* 321:    */     public void setLineZoomFactor(int paramInt)
/* 322:    */     {
/* 323:292 */       this.a = paramInt;
/* 324:    */     }
/* 325:    */     
/* 326:    */     public int getLineSpan()
/* 327:    */     {
/* 328:296 */       return this.b;
/* 329:    */     }
/* 330:    */     
/* 331:    */     public void setLineSpan(int paramInt)
/* 332:    */     {
/* 333:300 */       this.b = paramInt;
/* 334:    */     }
/* 335:    */     
/* 336:    */     public Color getLineColor()
/* 337:    */     {
/* 338:304 */       return this.c;
/* 339:    */     }
/* 340:    */     
/* 341:    */     public void setLineColor(Color paramColor)
/* 342:    */     {
/* 343:308 */       this.c = paramColor;
/* 344:    */     }
/* 345:    */     
/* 346:    */     public boolean isVisible()
/* 347:    */     {
/* 348:312 */       return this.d;
/* 349:    */     }
/* 350:    */     
/* 351:    */     public void setVisible(boolean paramBoolean)
/* 352:    */     {
/* 353:316 */       this.d = paramBoolean;
/* 354:    */     }
/* 355:    */   }
/* 356:    */ }



/* Location:           E:\idea\

 * Qualified Name:     org.intellij.images.ui.ImageComponent

 * JD-Core Version:    0.7.0.1

 */